package com.jia.videos.controller;


import com.jia.videos.common.dto.MemberDto;
import com.jia.videos.common.lang.R;
import com.jia.videos.entity.Member;
import com.jia.videos.service.MemberService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dujiajia
 * @since 2020-12-21
 */
@RestController
@RequestMapping("/videos/member")
@CrossOrigin
@Api(tags = "会员管理")
public class MemberController {

    @Autowired
    MemberService memberService;

    @PostMapping("logins")
    public R logins(@RequestBody Member member) {
        MemberDto members = memberService.logins(member);
        return R.ok().data("data",members);
    }

    @GetMapping("info/{id}")
    public R info(@PathVariable Long id) {
        Member member = memberService.getById(id);
        return R.ok().data("data",member);
    }
    @PostMapping("save")
    public R save(@RequestBody Member member) {
        memberService.save(member);
        return R.ok();
    }
    @PutMapping("update")
    public R update(@RequestBody Member member) {
        memberService.updateById(member);
        return R.ok();
    }

    @DeleteMapping("delete/{id}")
    public R delete(@PathVariable Long id) {
        memberService.removeById(id);
        return R.ok();
    }


}

